package cn.seecoder.courselearning.controller.course;

import cn.seecoder.courselearning.dto.course.CourseQuestionDTO;
import cn.seecoder.courselearning.dto.course.CourseTestDTO;
import cn.seecoder.courselearning.dto.course.CourseTestFinishDTO;
import cn.seecoder.courselearning.dto.course.CourseTestQuestionAddDTO;
import cn.seecoder.courselearning.service.course.CourseTestService;
import cn.seecoder.courselearning.vo.ResultVO;
import cn.seecoder.courselearning.vo.course.test.CourseQuestionVO;
import cn.seecoder.courselearning.vo.course.test.CourseTestVO;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/course-test")
public class CourseTestController {
    @Resource
    CourseTestService courseTestService;

    @PostMapping("/questionCreate")
    ResultVO createQuestion(@RequestBody CourseQuestionDTO courseQuestionDTO){
        return courseTestService.createQuestion(courseQuestionDTO);
    }

    @PostMapping("/questionFix")
    ResultVO fixQuestion(@RequestBody CourseQuestionDTO courseQuestionDTO){
        return courseTestService.fixQuestion(courseQuestionDTO);
    }

    @PostMapping("/questionDelete")
    ResultVO deleteQuestion(@RequestBody CourseQuestionDTO courseQuestionDTO){
        return courseTestService.deleteQuestion(courseQuestionDTO);
    }

    @GetMapping("/questionGet/course/{courseId}")
    ResultVO<List<CourseQuestionVO>> getQuestionsByCourseId(@PathVariable int courseId){
        return courseTestService.getQuestionsByCourseId(courseId);
    }

    @GetMapping("/questionGet/test/{testId}")
    ResultVO<List<CourseQuestionVO>> getQuestionsByTestId(@PathVariable int testId){
        return courseTestService.getQuestionsByTestId(testId);
    }

    @PostMapping("/testAddQuestion")
    ResultVO addTestQuestion(@RequestBody CourseTestQuestionAddDTO courseTestQuestionAddDTO){
        return courseTestService.addTestQuestion(courseTestQuestionAddDTO);
    }

    @PostMapping("/testAnswerCommit")
    ResultVO finishTest(@RequestBody CourseTestFinishDTO courseTestFinishDTO){
        return courseTestService.finishTest(courseTestFinishDTO);
    }

    @PostMapping("/testCreate")
    ResultVO createTest(@RequestBody CourseTestDTO courseTestDTO){
        return courseTestService.createTest(courseTestDTO);
    }

    @PostMapping("/testFix")
    ResultVO fixQuestion(@RequestBody CourseTestDTO courseTestDTO){
        return courseTestService.fixTest(courseTestDTO);
    }

    @PostMapping("/testDelete")
    ResultVO deleteQuestion(@RequestBody CourseTestDTO courseTestDTO){
        return courseTestService.deleteTest(courseTestDTO);
    }

    @GetMapping("/testGet/teacher/{{teacherId}}")
    ResultVO<List<CourseTestVO>> getTestsByTeacherId(@PathVariable int teacherId){
        return courseTestService.getTestsByTeacherId(teacherId);
    }

    @GetMapping("/testGet/course/{courseId}")
    ResultVO<List<CourseTestVO>> getTestsByCourseId(@PathVariable int courseId){
        return courseTestService.getTestsByCourseId(courseId);
    }



}
